Performs one of several blocks of statements for a condition with more than two outcomes. Compares the result of an expression against values in one or more Case statements. Statements in a Case block are only performed if the result of the expression matches the result of the expression in the Select...Case statement. If there is not a match, you can use a Case Else statement to run alternate statements. See Case.
Note: Case statements cannot have multiple delimited values. Define only one value per Case statement.
Syntax
Select Case TestExpression
[Case Expression
[Statements-n]]...
[Case Else Expression
[ElseStatements-n]]
End Select
Arguments
| Argument | Description |
|---|---|
| TestExpression | Numeric or string expression. For example, a > b, a < b, a = b, or a <> b. |
| Expression | Numeric or string expression. |
| Statements-n | One or more statements to run if TestExpression matches any part of Expression. |
| ElseStatements-n | One or more statements to run if TestExpression does not match any of the Case statements. |
Note: The Case statement is separate from Select...Case in the Add Statement dialog box.
Example
SRand()
random = Rand(1, 5)
Select Case random
Case 1
PrintLn("1 is the random number")
Case 2
PrintLn("Random number is 2")
Case 3
PrintLn("Number 3 was randomly generated")
Case 4
PrintLn("Random value = 4")
Case Else
PrintLn("Number 5 was chosen")
End Select